<?php

namespace addons\baiduwebtongji;

use app\common\library\Menu;
use think\Addons;

/**
 * 百度网站统计插件
 */
class Baiduwebtongji extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'baiduwebtongji',
                'title'   => '百度网站统计',
                'icon'    => 'fa fa-line-chart',
                'sublist' => [
                    [
                        'name'    => 'baiduwebtongji/index',
                        'title'   => '网站概况',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/index/index', 'title' => '查看']
                        ]
                    ],
                    [
                        'name'    => 'baiduwebtongji/latest',
                        'title'   => '实时访客',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/latest/index', 'title' => '查看']
                        ]
                    ],
                    [
                        'name'    => 'baiduwebtongji/source',
                        'title'   => '访客来源',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/source/index', 'title' => '查看']
                        ]
                    ],
                    [
                        'name'    => 'baiduwebtongji/toppage',
                        'title'   => '受访页面',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/toppage/index', 'title' => '查看']
                        ]
                    ],
                    [
                        'name'    => 'baiduwebtongji/district',
                        'title'   => '地域分布',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/district/index', 'title' => '查看']
                        ]
                    ],
                    [
                        'name'    => 'baiduwebtongji/searchword',
                        'title'   => '搜索词',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/searchword/index', 'title' => '查看']
                        ]
                    ],
                    [
                        'name'    => 'baiduwebtongji/rank',
                        'title'   => '关键词排名',
                        'icon'    => 'fa fa-circle-o',
                        'sublist' => [
                            ['name' => 'baiduwebtongji/rank/index', 'title' => '查看']
                        ]
                    ]
                ]
            ]
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete('baiduwebtongji');
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable('baiduwebtongji');
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable('baiduwebtongji');
    }

}
